import 'package:kmxy_base/base/base_package.dart';
import 'package:kmxy_base/page/signature/signature_page_state.dart';
import 'package:signature/signature.dart';

/// 签名界面
// ignore: must_be_immutable
class SignaturePage extends BasePage {
  SignaturePage({Key? key, arguments}) : super(key: key, arguments: arguments);
  @override
  SignaturePageView createState() => SignaturePageView();
}

class SignaturePageView extends SignaturePageState {
  @override
  Widget setPageContent(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        centerTitle: widget.arguments?['style']['centerTitle'] ?? true,
        backgroundColor:
            widget.arguments?['style']['backgroundColor'] ?? Colors.white,
        title: Text(
          widget.arguments?['style']['title'] ?? '签名',
          style: TextStyle(
            color: widget.arguments?['style']['color'] ?? Colors.black,
            fontSize: widget.arguments?['style']['fontSize'] ?? 16.sp,
            fontWeight:
                widget.arguments?['style']['fontWeight'] ?? FontWeight.w700,
          ),
        ),
        actions: <Widget>[
          InkWell(
            onTap: clean,
            child: Container(
              alignment: Alignment.center,
              padding: EdgeInsets.symmetric(horizontal: 20.w),
              child: const Text('清空'),
            ),
          ),
        ],
      ),
      body: SafeArea(
        child: Column(
          children: [
            Expanded(
              child: Signature(
                controller: controller,
                height: MediaQuery.of(context).size.height,
                backgroundColor: Colors.white,
              ),
            ),
            InkWell(
              onTap: save,
              child: Container(
                height: 50.w,
                color: Colors.blue,
                alignment: Alignment.center,
                child: const Text(
                  '保存',
                  style: TextStyle(color: Colors.white),
                ),
              ),
            )
          ],
        ),
      ),
    );
  }
}
